package com.algernoon.rpc.springrpc.rmi.spring;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.rmi.RmiServiceExporter;

@Configuration
public class SpringRmiServerConfig {

	Logger logger = LoggerFactory.getLogger(SpringRmiServerConfig.class);
	
	@Autowired
	@Qualifier("springUserServiceImpl")
	private ISpringUserService userService;
	
	@Bean
	public RmiServiceExporter rmiExporter() {
		RmiServiceExporter rmiExporter = new RmiServiceExporter();
		rmiExporter.setServiceInterface(ISpringUserService.class);
		rmiExporter.setService(userService);
		rmiExporter.setServiceName("SpringUserService");
		rmiExporter.setServicePort(6666);
		rmiExporter.setRegistryPort(1199);
		return rmiExporter;
	}
	
}
